package cn.donting.jme.expansion.attribute.lmpl;

import javax.swing.*;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;

public class StringAttribute extends AbsLineAttribute<String,JTextField> implements DocumentListener{

    public StringAttribute(String title) {
        super(new JTextField());
        inputComponent.getDocument().addDocumentListener(this);
        setTitle(title);
    }

    @Override
    public void setValue(String value) {
        inputComponent.setText(value);
    }


    @Override
    public void insertUpdate(DocumentEvent e) {
        valueChange(getValue());
    }

    @Override
    public void removeUpdate(DocumentEvent e) {
        valueChange(getValue());
    }

    @Override
    public void changedUpdate(DocumentEvent e) {

    }
    @Override
    protected String getInputValue() {
        return inputComponent.getText();
    }
}
